<template>
	<view>
		<view class="u-padding-20" style="background-color: #0c838b;">
			<u-search v-model="keyword" :show-action="true" action-text="搜索" :animation="true" @search="search" @custom="search"></u-search>
		</view>
		
		<!-- <view style="height:30rpx;"></view> -->
		<u-index-list :scrollTop="scrollTop" :indexList="index">
			<view v-for="(item, index) in indexList" :key="index">
				<u-index-anchor :use-slot="true">
					<text class="anchor-text">{{item.name}}</text>
				</u-index-anchor>
				<view class="list-cell u-rela" v-for="(ite, inde) in item.data" :key="inde">
					<u-avatar
						:src="ite.avatar" size="80"
						mode="circle"></u-avatar>
					<!-- <image class="va_m" :src="ite.avatar"></image> -->
					<text class="va_m u-margin-left-20">{{ite.post}}</text>
					<text class="va_m u-margin-left-20">{{ite.name}}</text>
					<u-icon style="top:25rpx; right:60rpx;" class="u-abso" :customStyle="{marginRight: '50rpx'}" color="#008987" name="chat-fill" size="45" @click="intoChat(ite)"></u-icon>
					<u-icon style="top:25rpx;" class="u-abso pos_right" color="#008b00" name="phone-fill" size="45" @click="makephone(ite.phone)"></u-icon>
				</view>
				
			</view>
		</u-index-list>
		<u-top-tips ref="uTips"></u-top-tips>
		<!-- <u-tabbar v-model="current" :list="vuextabbar" :mid-button="false"></u-tabbar> -->
	</view>
</template>

<script>
	import {
		getStaffList,
		searchStaff
	} from "@/service/indexService.js";
	export default {
		data() {
			return{
				current: 0,
				
				keyword:'',
				scrollTop: 0,
				index:[],
				indexList: [],
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		onLoad() {
			getStaffList().then(this.getStaffList);
		},
		methods:{
			getStaffList:function(e){
				if(e.code==200){
					this.indexList=e.result
				}else{
					
				}
			},
			makephone:function(phone){
				uni.makePhoneCall({
					phoneNumber:phone,
					success(e) {
						console.log(e);
					}
				})
			},
			search:function(){
				searchStaff({
					keyword:this.keyword
				}).then(res=>{
					if(res.code==200){
						this.indexList=res.result
					}else{
						this.$refs.uTips.show({
							title: '暂无数据',
							type: 'warning',
							duration: '2000'
						})
					}
				});
			},
			intoChat(item) {
				console.log(item);
				this.$u.route({
					url: '/pages/message/chat',
					params: {
						sid: item.id,
						nickname: item.nickname,
						avatar: item.avatar
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		background-color: #fff;
	}
	.anchor-text {
		padding:20rpx 0;
		color: #006971;
	}
	.list-cell image{
		width:80rpx;
		height:80rpx;
		border-radius: 50%;
	}
	.list-cell text{
		line-height: 80rpx;
	}
</style>
